<!--
 * @FilePath: DormitScroll.vue
 * @Author: jack
 * @Date: 2025-03-20 13:58:39
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2025-04-08 09:07:11
 * Copyright: 2025 xxxTech CO.,LTD. All Rights Reserved.
 * @Descripttion: 
-->
<template>
    <dv-scroll-board v-if="dataNum.length > 0" :config="tableConfig" ref="scrollBoard"
        :style="'width:100%;height:' + dataNumHeight + 'px;'" />
</template>
<script>
import $util from '../util/util'
export default {
    // components: {
    //     NoDate
    // },
    props: {
        // 床位集合
        dataNum: {
            type: Array,
            default: []
        },
        dataNumBol: {
            type: Boolean,
            default: false
        },
        dataNumHeight: {
            type: Number,
            default: 0
        },
        nodatedataNumHeight: {
            type: Number,
            default: 0
        },
        inOutStatus: {
            type: String,
            default: ''
        },
    },
    data() {
        return {
            lastData: [],
            innerHeight: window.innerHeight,
            tableConfig: {
                header: [
                    `<span style="font-weight: 500;font-size:${$util.nowSize(22)}px;">寝室</span>`,
                    `<span style="font-weight: 500;font-size:${$util.nowSize(22)}px;">${Number(this.inOutStatus) !== 1 ? '已归宿' : '已离宿'}</span>`,
                    `<span style="font-weight: 500;font-size:${$util.nowSize(22)}px;">${Number(this.inOutStatus) !== 1 ? '未归宿' : '未离宿'}</span>`,
                    `<span style="font-weight: 500;font-size:${$util.nowSize(22)}px;">${Number(this.inOutStatus) !== 1 ? '晚归' : '晚出'}学生</span>`
                ],
                data: this.cycleOneList,
                columnWidth: [$util.nowSize(240)],
                align: ['center', 'center', 'center', 'center'],
                headerBGC: 'transparent',
                rowNum: Math.floor(Number(this.dataNumHeight) / $util.nowSize(60)),
                headerHeight: 48,
                hoverPause: true,
                oddRowBGC: 'transparent',
                evenRowBGC: 'rgba(18,108,254,0.11)'
            }
        }
    },
    watch: {
        dataNum: {
            handler: function (newValue, oldValue) {
                if (JSON.stringify(newValue) !== JSON.stringify(oldValue) && oldValue.length !== 0) {
                    this.$refs.scrollBoard.updateRows(this.dataNum)
                } else {
                    this.Innit()
                }
            },
            deep: true,
            // immediate: true
        },
        dataNumHeight: {
            handler: function (newValue, oldValue) {
                this.Innit()
            }
        },
    },
    methods: {
        Innit() {
            this.$nextTick(() => {
                setTimeout(() => {
                    if (this.dataNum) {
                        if (!this.dataNumBol) {
                            const params = {
                                header: [
                                    `<span style="font-weight: 500;font-size:${$util.nowSize(22)}px;">寝室</span>`,
                                    `<span style="font-weight: 500;font-size:${$util.nowSize(22)}px;">${Number(this.inOutStatus) !== 1 ? '已归宿' : '已离宿'}</span>`,
                                    `<span style="font-weight: 500;font-size:${$util.nowSize(22)}px;">${Number(this.inOutStatus) !== 1 ? '未归宿' : '未离宿'}</span>`,
                                    `<span style="font-weight: 500;font-size:${$util.nowSize(22)}px;">${Number(this.inOutStatus) !== 1 ? '晚归' : '晚出'}学生</span>`
                                ],
                                data: this.dataNum,
                                columnWidth: [$util.nowSize(240)],
                                align: ['center', 'center', 'center', 'center'],
                                headerBGC: 'transparent',
                                rowNum: Math.floor(Number(this.dataNumHeight) / $util.nowSize(60)),
                                headerHeight: 48,
                                hoverPause: true,
                                oddRowBGC: 'transparent',
                                evenRowBGC: 'rgba(18,108,254,0.11)'
                            }
                            this.tableConfig = params
                            this.$emit('setdataNumBol', false)
                        } else {
                        }
                    }
                })
            })
        }
    },
    async mounted() {
        this.Innit()
    }
}
</script>
<style lang="less" scoped>
.dv-scroll-board {
    margin-top: 10px;
}
</style>
